package instructions;

import base.Environment;

public class Composition implements Instruction {

	private Instruction son1;
	private Instruction son2;
	
	/**
	 * creates the composition of two instructions 
	 */
	public Composition (Instruction son1, Instruction son2) {
	
		this.son1 = son1;
		this.son2 = son2;
	}
	
	/**
	 * executes the two instructions, son1 then son2
	 */
	public Environment instr(Environment env) throws BadInstructionException {
		
		Environment tempEnv = son1.instr(env);
		
		return son2.instr(tempEnv);
	}

}
